//--------------------------------------------------------------------------------------
// register the function
 var newRegistery1 = new Array("getPlayerMainViewData2", "cretateTableToEnterView" ); 
 allJsonsRegistry = allJsonsRegistry.concat(newRegistery1);
 
 
//--------------------------------------------------------------------------------------
// mostly read the data for the request and call the function making the request
function enterView0(url)
{
    return submitWithoutReload( 
        url,
        $('#id_inputViewTable'),
        '#id_messageDiv',
        '',
        function(){
                $('#id_messageDiv').text( 'Thanks, your bet has successfully been taken into account.' );
                setTimeout( function() { $('#id_messageDiv').fadeOut(); }, 3000 );
                return false; 
             }
        );
}


//--------------------------------------------------------------------------------------
// implement the function
// fill the table displaying the set percentages in the mtm repartition. the current mtm repartition (which coul be different
// from the set percentages because the market could have moved. and a column to set new percentages.
function cretateTableToEnterView(playerTableInfoDictionary) 
{
    
    var mySection = document.getElementById('id_enterView');
    var myUrl = '\'' + document.getElementById('id_urlToCall').value+'\'';
    if( playerTableInfoDictionary.assetsList.length == 0 )
    {
        mySection.innerHTML = '';
    }
    else
    {
        var str ='<div class="section">';
        str += '    <h2>Make your bet</h2>';
        str += '    <div class="myLeft2" style="display:table;">';
        str += '     <table id="id_inputViewTable" ></table>';
        str += '     <input class="myRoundCorners" type="submit" value="Set my bet" onclick="enterView0('+myUrl +');"/>';
        str += '     <div class="oneLine" id="id_messageDiv" style="color:Red;"></div>';
        str += '    </div>';
        str += '</div>';
        mySection.innerHTML = str;
        var myTable = document.getElementById('id_inputViewTable');
        // add the header
        var headerRow = myTable.insertRow(0);
        var newCell = headerRow.insertCell(0);
        newCell.innerHTML = '<th ><div class="myBold">Asset</div></th>';
        newCell = headerRow.insertCell(1);
        newCell.innerHTML = '<th ><div class="myBold">Enter Percentage</div></th>';
        var QuoteAndonEventStringAndEnd = '" onkeypress="ifEnterArg(this, event, enterView0,'+myUrl+' );" ></td>';
        for (var i = 0; i < playerTableInfoDictionary.assetsList.length; i++)
        {
              var newRow = myTable.insertRow(i+1);
              var newCell = newRow.insertCell(0);
              var name0 = playerTableInfoDictionary.assetsList[i].name;
              var rep0 = Math.round( playerTableInfoDictionary.assetsList[i].playerView*10000 )/100;
              newCell.innerHTML = name0;
              newCell = newRow.insertCell(1);
              newCell.innerHTML = '<td> <input name="'+name0+'" type="text" size="10%" value="'+ rep0 + QuoteAndonEventStringAndEnd;
        }
        attachCSS3Properties();
    }
    return false;
};